package excercise;

import java.util.Scanner;

public class EX03_Q32 {
	
	
	
	public static void main(String[] args) {
		/*
				
				
				주민번호 유효성 검사
				123456-1234567
				1 * 2 + 2 * 3 + 3 * 4 + 4 * 5 + 5 * 6 + 6 * 7
				1 * 8 + 2 * 9 + 3 * 2 + 4 * 3 + 5 * 4 + 6 * 5
				
		*/
		
		
		//
		/*
				
				123456일때
				
				123456 / 10000 = 1
				123456 % 100000 = 23456
				23456 / 10000 = 2
				23456 % (2 * 10000) = 3456
				3456 / 1000 = 3
				3456 % (3 * 1000) = 456
				456 / 100 = 4
				456 % (4 * 100) = 56
				56 / 10 = 5
				
				
		*/
		
		
		long jumin = 1234561234567L;
		
		int key = 0;			//추출된 각 자릿수 값
		
		int total = 0;
		
		//첫번째 자리
		key = (int)(jumin / 1000000000000L);
		total = total + (key * 2);
		if(key > 0) jumin = jumin % (key * 1000000000000L);
		
		//두번째 자리
		key = (int)(jumin / 100000000000L);
		total = total + (key * 3);
		if(key > 0) jumin = jumin % (key * 100000000000L);
		
		//세번째 자리
		key = (int)(jumin / 10000000000L);
		total = total + (key * 4);
		if(key > 0) jumin = jumin % (key * 10000000000L);
		
		//네번째 자리
		key = (int)(jumin / 1000000000L);
		total = total + (key * 5);
		if(key > 0) jumin = jumin % (key * 1000000000L);
		
		//다섯번째 자리
		key = (int)(jumin / 100000000L);
		total = total + (key * 6);
		if(key > 0) jumin = jumin % (key * 100000000L);
		
		//여섯번째 자리
		key = (int)(jumin / 10000000L);
		total = total + (key * 7);
		if(key > 0) jumin = jumin % (key * 10000000L);
		
		//일곱번째 자리
		key = (int)(jumin / 1000000L);
		total = total + (key * 8);
		if(key > 0) jumin = jumin % (key * 1000000L);
		
		//여덟번째 자리
		key = (int)(jumin / 100000L);
		total = total + (key * 9);
		if(key > 0) jumin = jumin % (key * 100000L);
		
		//아홉번째 자리
		key = (int)(jumin / 10000L);
		total = total + (key * 2);
		if(key > 0) jumin = jumin % (key * 10000L);
		
		//열번째 자리
		key = (int)(jumin / 1000L);
		total = total + (key * 3);
		if(key > 0) jumin = jumin % (key * 1000L);
		
		//열한번째 자리
		key = (int)(jumin / 100L);
		total = total + (key * 4);
		if(key > 0) jumin = jumin % (key * 100L);
		
		//열두번째 자리
		key = (int)(jumin / 10L);
		total = total + (key * 5);
		if(key > 0) jumin = jumin % (key * 10L);
		
		System.out.println(jumin);
		System.out.println(total);
		System.out.println(total % 11);
		
		//열세번째자리와 비교
		if( (11 - (total % 11)) > 9){
			if( (11 - (total % 11)) % 10 == jumin){
				System.out.println("주민등록번호의 유효성이 맞습니다.");
				System.out.println("정상적인 주민등록 번호 입니다.");
			}else
			System.out.println("주민등록번호의 유효성이 맞지 않습니다.");
			
		}else if( (11 - (total % 11)) == jumin){
			
			System.out.println("주민등록번호의 유효성이 맞습니다.");
			System.out.println("정상적인 주민등록 번호 입니다.");
			
		}
		
		
		System.out.println(Math.pow(10, 12));
		
		int total2 = 0;
		
		int key2 = 0;
		
		for(long i = 1000000000000L, prime = 2; i >= 10; i /= 10, ++prime){
			
			if(prime > 9) prime = 2;
			
			key = (int)(jumin / i);
			total2 = total2 + (int)(key2 * prime);
			if(key2 > 0) jumin = jumin % (key2 * i);
			
		}
		
		if( (11 - (total2 % 11)) > 9){
			if( (11 - (total2 % 11)) % 10 == jumin){
				System.out.println("주민등록번호의 유효성이 맞습니다.");
				System.out.println("정상적인 주민등록 번호 입니다.");
			}else
			System.out.println("주민등록번호의 유효성이 맞지 않습니다.");
		}
		
		/*
		
		int key = (int)(jumin/1000000000000L);
		
		System.out.println(key);
		
		key = (int)(jumin/100000000000L);
		
		System.out.println(key - 10);
		key = (int)(jumin/10000000000L);
		
		System.out.println(key - 120);
		key = (int)(jumin/1000000000L);
		
		System.out.println(key - 1230);
		key = (int)(jumin/100000000L);
		
		System.out.println(key - 12340);
		key = (int)(jumin/10000000L);
		
		System.out.println(key - 123450);
		key = (int)(jumin/1000000L);
		
		System.out.println(key - 1234560);
		key = (int)(jumin/100000L);
		
		System.out.println(key - 12345610);
		key = (int)(jumin/10000L);
		
		System.out.println(key - 123456120);
		key = (int)(jumin/1000L);
		
		System.out.println(key - 1234561230);
		key = (int)(jumin/100L);
		
		System.out.println(key - 1234561234);
		
		*/
		
		
	}

}